/**
 * description：对stream_copy_logo进行扩展
 * author：洪俊勇
 * createTime：2017/8/27
 * version:1.0.0.0
 * history:
 *   1、
 *   2、
 */
var fs = require('fs')
var n = 0;

var readStream = fs.createReadStream('stream_copy_logo.js')

readStream
    .on('data',function (chunk) {
        n++
        console.log('data emits')
        console.log(Buffer.isBuffer(chunk))
        // console.log(Buffer.toString('utf8'))

        readStream.pause()
        console.log('data pause')
        setTimeout(function (args) {
            console.log('data pause end')
            readStream.resume()
        },3000)

    })
    .on('readable',function () {
        console.log('data readable')
    })
    .on('end',function () {
        console.log(n)
        console.log('data ends')
    })
    .on('close',function () {
        console.log('data close')
    })
    .on('error',function (e) {
        console.log('data read error' + e)
    })